package com.demo.valuestream;

import java.util.stream.IntStream;
import java.util.stream.Stream;

public class TestRange {
    public static void main(String[] args) {
        IntStream evenNumbers = IntStream.rangeClosed(1, 100)
                                         .filter(n -> n % 2 == 0);
        //evenNumbers.forEach(System.out::println);

        Stream<int[]> pythagoreanTriples =
                IntStream.rangeClosed(1, 100).boxed()
                         .flatMap(a ->
                               IntStream.rangeClosed(a, 100)
                                        .filter(b -> Math.sqrt(a * a + b * b) % 1 == 0)
                                        .mapToObj(b -> new int[]{a, b, (int)Math.sqrt(a * a + b * b)}));
        pythagoreanTriples.forEach(a -> System.out.println(a[0] + " " + a[1] + " " + a[2]));
    }
}
